package scauCmiScaffolding.compiled;

import org.eclipse.jet.JET2Context;
import org.eclipse.jet.JET2Template;
import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.taglib.RuntimeTagElement;
import org.eclipse.jet.taglib.TagInfo;

public class _jet_deleteEntity implements JET2Template {
    private static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$

    public _jet_deleteEntity() {
        super();
    }

    private static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
    
    private static final TagInfo _td_c_get_1_30 = new TagInfo("c:get", //$NON-NLS-1$
            1, 30,
            new String[] {
                "select", //$NON-NLS-1$
            },
            new String[] {
                "uppercaseFirst($eachTable/@name)", //$NON-NLS-1$
            } );
    private static final TagInfo _td_c_get_1_122 = new TagInfo("c:get", //$NON-NLS-1$
            1, 122,
            new String[] {
                "select", //$NON-NLS-1$
            },
            new String[] {
                "lowercaseFirst($eachTable/@name)", //$NON-NLS-1$
            } );
    private static final TagInfo _td_c_get_2_49 = new TagInfo("c:get", //$NON-NLS-1$
            2, 49,
            new String[] {
                "select", //$NON-NLS-1$
            },
            new String[] {
                "lowercaseFirst($eachTable/@name)", //$NON-NLS-1$
            } );

    public void generate(final JET2Context context, final JET2Writer __out) {
        JET2Writer out = __out;
        out.write("    public static void delete");  //$NON-NLS-1$        
        RuntimeTagElement _jettag_c_get_1_30 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _td_c_get_1_30); //$NON-NLS-1$ //$NON-NLS-2$
        _jettag_c_get_1_30.setRuntimeParent(null);
        _jettag_c_get_1_30.setTagInfo(_td_c_get_1_30);
        _jettag_c_get_1_30.doStart(context, out);
        _jettag_c_get_1_30.doEnd();
        out.write("(final Handler handler,final int what,int ");  //$NON-NLS-1$        
        RuntimeTagElement _jettag_c_get_1_122 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _td_c_get_1_122); //$NON-NLS-1$ //$NON-NLS-2$
        _jettag_c_get_1_122.setRuntimeParent(null);
        _jettag_c_get_1_122.setTagInfo(_td_c_get_1_122);
        _jettag_c_get_1_122.doStart(context, out);
        _jettag_c_get_1_122.doEnd();
        out.write("Id){");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        String url = Url + \"/\" + String.valueOf(");  //$NON-NLS-1$        
        RuntimeTagElement _jettag_c_get_2_49 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _td_c_get_2_49); //$NON-NLS-1$ //$NON-NLS-2$
        _jettag_c_get_2_49.setRuntimeParent(null);
        _jettag_c_get_2_49.setTagInfo(_td_c_get_2_49);
        _jettag_c_get_2_49.doStart(context, out);
        _jettag_c_get_2_49.doEnd();
        out.write("Id);//相关，与后台Controller中url一致");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        final Message msg = new Message();");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        msg.what = what;");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        final Bundle bundle = new Bundle();");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        try{");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("            HttpUtil.deleteData(url, new Callback() {");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                @Override");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                public void onFailure(@NotNull Call call, @NotNull IOException e) {");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    if(e.getCause().equals(SocketTimeoutException.class)){");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                        //do something while connect timeout");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    }");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    bundle.putInt(KeyData.resultCode,KeyData.RESULT_FAILURE);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    msg.setData(bundle);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    handler.sendMessage(msg);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                }");  //$NON-NLS-1$        
        out.write(NL);         
        out.write(NL);         
        out.write("                @Override");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    bundle.putInt(KeyData.resultCode,KeyData.RESULT_SUCCESS);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    msg.setData(bundle);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    handler.sendMessage(msg);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                }");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("            });");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        }catch (IOException e){");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("            //do something");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        }");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("    }");  //$NON-NLS-1$        
    }
}
